package com.kordar.api.modular.unicomJS;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import java.text.SimpleDateFormat;
import java.util.Date;

@Data
public class ZOPPreOrderRequestImpl implements Request {

    @NotEmpty(message = "{zop.goodsId}{javax.validation.constraints.NotEmpty.message}")
    private String goodsId;

    @NotEmpty(message = "{zop.certName}{javax.validation.constraints.NotEmpty.message}")
    private String certName;

    @NotEmpty(message = "{zop.certNo}{javax.validation.constraints.NotEmpty.message}")
    private String certNo;

    @NotEmpty(message = "{zop.contactNum}{javax.validation.constraints.NotEmpty.message}")
    private String contactNum;

    @NotEmpty(message = "{zop.channel}{javax.validation.constraints.NotEmpty.message}")
    private String channel;

    @NotEmpty(message = "{zop.postProvinceCode}{javax.validation.constraints.NotEmpty.message}")
    private String postProvinceCode;

    @NotEmpty(message = "{zop.postProvince}{javax.validation.constraints.NotEmpty.message}")
    private String postProvince;

    @NotEmpty(message = "{zop.postCityCode}{javax.validation.constraints.NotEmpty.message}")
    private String postCityCode;

    @NotEmpty(message = "{zop.postCity}{javax.validation.constraints.NotEmpty.message}")
    private String postCity;

    @NotEmpty(message = "{zop.postDistrictCode}{javax.validation.constraints.NotEmpty.message}")
    private String postDistrictCode;

    @NotEmpty(message = "{zop.postDistrict}{javax.validation.constraints.NotEmpty.message}")
    private String postDistrict;

    @NotEmpty(message = "{zop.postAddr}{javax.validation.constraints.NotEmpty.message}")
    private String postAddr;

    private String number;

    /**
     * thirdOrderId	body	是	String		接入方订单号TP+拼接25位字符串,保证唯一性
     * goodsId	body	是	String		商品ID
     * certName	body	是	String		入网人姓名
     * certNo	body	是	String		入网人证件号码(证件号中的X要求大写)
     * contactNum	body	是	String		入网人联系电话
     * channel	body	是	String		渠道编码
     * postProvinceCode	body	是	String		收货省份编码
     * postCityCode	body	是	String		收货地市编码
     * postDistrictCode	body	是	String		收货区县编码
     * postAddr	body	是	String		收货详细地址
     * createTime	body	是	String		订单创建时间(yyyy-MM-dd HH:mm:ss)
     * updateTime	body	是	String		订单更新时间
     * @return JSONObject
     */
    @Override
    public JSONObject body() {
        JSONObject object = new JSONObject();
        object.put("thirdOrderId", number);
        object.put("goodsId", goodsId);
        object.put("certName", certName);
        object.put("certNo", certNo);
        object.put("contactNum", contactNum);
        object.put("channel", channel);
        object.put("postProvinceCode", postProvinceCode);
        object.put("postCityCode", postCityCode);
        object.put("postDistrictCode", postDistrictCode);
        object.put("postAddr", postAddr);
        object.put("createTime", SysParams.getTimestamp());
        object.put("updateTime", SysParams.getTimestamp());
        return object;
    }

    @Override
    public String url() {
        return "http://58.240.52.214:80/jszop/zop_link/preOrder?secretKey=" + SysParams.SYS_SECRET_KEY.getName();
    }
}
